package com.xgkj.diyiketang.task;

import com.alibaba.fastjson.JSONObject;
import com.xgkj.diyiketang.http.CouponHttpRequest;
import com.xgkj.diyiketang.http.CouponHttpResponse;
import com.xgkj.diyiketang.http.engine.CouponHttpBaseTask;

/**
 * Created by jayc on 2017/4/11.
 * Email:cnjiaqi@sina.com
 */
public class SubSchoolTask extends CouponHttpBaseTask {
    private String schoolALL;
    private String youeryuan;
    private String xiaoxue;
    private String chuzhong;
    private String gaozhong;
    private String daxue;
    private String shuoshi;
    private String boshi;
    private String workunit;

    public SubSchoolTask(String schoolALL, String youeryuan, String xiaoxue, String chuzhong, String gaozhong, String daxue, String shuoshi, String boshi, String workunit) {
        super(TaskType.SUBSCHOOL_TASK);
        this.schoolALL = schoolALL;
        this.youeryuan = youeryuan;
        this.xiaoxue = xiaoxue;
        this.chuzhong = chuzhong;
        this.gaozhong = gaozhong;
        this.daxue = daxue;
        this.shuoshi = shuoshi;
        this.boshi = boshi;
        this.workunit = workunit;
    }

    @Override
    protected void processResponseData(CouponHttpResponse response) {
        notifyTaskCompleted(1, response.getBody());
    }


    @Override
    protected void prepareRequest() {
        super.prepareRequest();
        if (mPhase == TASK_PHASE_INIT) {
            CouponHttpRequest request = new CouponHttpRequest(RequestType.SubSCHOOL_REQUEST);
            JSONObject json = new JSONObject();
            json.put("schoolAll", schoolALL);
            json.put("youeryuan", youeryuan);
            json.put("xiaoxue", xiaoxue);
            json.put("chuzhong", chuzhong);
            json.put("gaozhong", gaozhong);
            json.put("daxue", daxue);
            json.put("shuoshi", shuoshi);
            json.put("boshi", boshi);
            json.put("work", workunit);

            request.setData(json.toString());
            request.setApiNo(ApiNo.SUBSCHOOL);
            addRequest(request);
        }
    }
}
